/*
 * MAX7456 osd high level functions library header
 *
 * Written by Florian MAZEN and Pierre COL, 2008-2009
 * <euronym AT free.fr>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#ifndef __OSD_H__
#define __OSD_H__

#define OSD_NTSC 0x00
#define OSD_PAL 0x01

#define OSD_SYNC_AUTO 0x00
#define OSD_SYNC_INT 0x01
#define OSD_SYNC_EXT 0x02

/* Characters attribute */
#define OSD_ATT_NORM 0x00
#define OSD_ATT_INV 0x01
#define OSD_ATT_BLK 0x02
#define OSD_ATT_LBC 0x04

/* Blinking Time (BT) */
#define OSD_BT_2 0x00	// 2 fields
#define OSD_BT_4 0x01	// 4 fields
#define OSD_BT_6 0x02	// 6 fields
#define OSD_BT_8 0x03	// 8 fields

/* Blinking Duty Cycle     on : off */
#define OSD_DC_1_1 0x00	// BT : BT
#define OSD_DC_1_2 0x01	// BT : 2*BT
#define OSD_DC_1_3 0x02	// BT : 3*BT
#define OSD_DC_3_1 0x03	// 3*BT : BT

//#define _XTAL_FREQ 40000000

/* Set the current character adress in osd format */
void osd_locate_absolute(unsigned int pos);

/* Set the current character adress in X Y format */
void osd_locate(unsigned char x, unsigned char y);

/* Get the current character adress */
unsigned int osd_getCharLocation(void);

/* Reset OSD device */
void osd_reset(void);

/* Clear display*/
void osd_cls(void);

/* Display a new character */
void osd_putchar(unsigned char c) ;

/* Display a formated string */
void osd_printf(char *fmt, ...);

/* Turn on or off osd display */
void osd_enable(void);
void osd_disable(void);

/* Set video standard (PAL, NTSC) and OSD sync mode (Auto, internal, external) */
void osd_setVideoMode(unsigned char standard, unsigned char sync);

/* Set attribute */
void osd_setCharactersAttribute(unsigned char att) ;
/* Get attribute */
unsigned char osd_getCharactersAttribute(void);

/* Set the level of gray of the background 
  Values can be 0. to 7 */
void osd_setBackgroundBrightness(unsigned char level) ;
/* Get the current level of gray of the background */
unsigned char osd_getBackgroundBrightness(void);

/* Set blinking time parameter (BT) 
	blinkingTime duration from 0 to 3
  Check constants for values
*/
void osd_setBlinkingTime(unsigned char blinkingTime) ;

/* Set blinking time parameter
        blinkingTime duty cycle from 0 to 3
  Check constants for values
*/
void osd_setBlinkingDutyCycle(unsigned char blinkingDuty) ;

/* Get blinking time parameter (BT) */
unsigned char osd_getBlinkingTime(void);

/* Get blinking time parameter */
inline unsigned char osd_getBlinkingDutyCycle(void);

/* Set Horizontal Offset */
inline void osd_setHOS(unsigned char val) ;
/* Get Horizontal Offset */
inline unsigned char osd_getHOS(void);

/* Set Vertical Offset */
inline void osd_setVOS(unsigned char val) ;
/* Get Vertical Offset */
inline unsigned char osd_getVOS(void);

#endif	/* __OSD_H__ */
